//////////////////////////////////////////
// EMITTER BODY CLASS					//
//////////////////////////////////////////

class EmitterBody {
    constructor(svg, emitter) {
        this.svg = svg;
        this.emitter = emitter;

        this.svgBody = document.createElementNS(
            "http://www.w3.org/2000/svg",
            "circle"
        );
        this.svgBody.setAttribute("cx", "0");
        this.svgBody.setAttribute("cy", "0");
        this.svgBody.setAttribute("r", this.emitter.radius);
        this.svgBody.style.fill = "none";
        this.svgBody.style.stroke = "#000";
        this.svgBody.style.strokeWidth = "2px";

        //Add to document.
        this.svg.appendChild(this.svgBody);
    }

    die() {
        this.svg.removeChild(this.svgBody);
    }

    update() {
        this.svgBody.setAttribute("cx", this.emitter.position.x);
        this.svgBody.setAttribute("cy", this.emitter.position.y);
        this.svgBody.setAttribute("r", this.emitter.radius);

        if (!this.emitter.repel) {
            this.svgBody.style.fill = "#58D3F7";
            this.svgBody.style.stroke = "#58D3F7";
        } else {
            this.svgBody.style.fill = "#FE642E";
            this.svgBody.style.stroke = "#FE642E";
        }

        this.svgBody.setAttribute("fill-opacity", "0.05");
        this.svgBody.setAttribute("stroke-opacity", "0.3");
    }
}

export { EmitterBody };
